<?php

namespace App\Service\Admin;

use App\Model\Admin\DictionaryModel;
use App\Service\BaseService;

/**
 * 数据字典管理-服务类
 * @author LZH
 * @since: 2021/08/12
 * Class DictionaryService
 */
class DictionaryService extends BaseService
{
    /**
     * 构造函数
     * LevelService constructor.
     */
    public function __construct()
    {
        $this->model = new DictionaryModel();
        parent::__construct();
    }

    /**
     * 获取数据列表
     * @return array
     * @since 2021/08/12
     * @author LZH
     */
    public function getList()
    {
        $param = $this->getRequestParam();
        // 查询条件
        $map = [];
        // 字典类型ID
        $dicttypeId = $param['dictTypeId'];
        if ($dicttypeId) {
            $map[] = ['dict_type_id' => [$dicttypeId]];
        }
        // 字典名称
        $name = $param['name'];
        if ($name) {
            $map[] = ['name' => ["%{$name}%", 'like']];
        }
        // 字典编码
        $code = $param['code'];
        if ($code) {
            $map[] = ['code', '=', $code];
        }
        return parent::getList($map, ["sort" => "asc"]);
    }
}
